# -*- coding: utf-8 -*-
'''
题目：古典问题：有一对兔子，从出生后第3个月起每个月都生一对兔子，
小兔子长到第三个月后每个月又生一对兔子，
假如兔子都不死，问每个月的兔子总数为多少？
'''
# mothod one
__author__='dupengfei'
import copy
def add_tuzi():
    L = {'1':1}
    n = 1
    while True:
        L_len = len(L)
        RL = copy.copy(L)
        for key,value in RL.items():
            if value >= 3:
                L[str(L_len+1)] = 1
                L_len += 1
        yield [n,len(L)*2]
#        L=dict(map(add_one,L.items()))
        n += 1
        for key,value in L.items():
                L[key] = value + 1
      
#m = 1
#for j in add_tuzi():
#    if m <100:
#        print(j)
#        m += 1
#    else:
#        break

# mothod two
def add_tuzi2():
    month = 1
    tuzi_num = 2
    while True:
        if month > 2:
            tuzi_num += tuzi_num
        yield [month,tuzi_num]
        month += 1
tuzi_sum=add_tuzi2()
for i,j in tuzi_sum:
    if i <100:
        print('第%s月的总兔子数为%s' %(i,j))
    else:
        break



    
